--The gui for picking teams.

/*---------------------------------------------------------
   Name: gamemode:ShowTeam( )
   Desc: 
---------------------------------------------------------*/
function GM:ShowTeam( )

	if ( IsValid(self.TeamSelectFrame) ) then return end

	// Basically this is the welcome/team selection/help menu
	self.TeamSelectFrame = vgui.Create( "DFrame" )
	self.TeamSelectFrame:SetTitle( "Welcome" )
	self.TeamSelectFrame:SetSize( 510, 380 )
	self.TeamSelectFrame:Center( )
	self.TeamSelectFrame:MakePopup( )
	self.TeamSelectFrame:SetKeyboardInputEnabled( false )
	
		local Team = vgui.Create( "DButton", self.TeamSelectFrame )
		function Team.DoClick( ) self:HideTeam( ) RunConsoleCommand( "join_combine" ) end
		Team:SetPos( 370, 85 )
		Team:SetSize( 130, 40 )
		Team:SetText( "Join Combine" )

		local Team = vgui.Create( "DButton", self.TeamSelectFrame )
		function Team.DoClick( ) self:HideTeam( ) RunConsoleCommand( "join_lambda" ) end
		Team:SetPos( 370, 135 )
		Team:SetSize( 130, 40 )
		Team:SetText( "Join Lambda" )
		
		local Team = vgui.Create( "DButton", self.TeamSelectFrame )
		function Team.DoClick( ) self:HideTeam( ) RunConsoleCommand( "changeteam", TEAM_SPECTATOR ) end
		Team:SetPos( 370, 185 )
		Team:SetSize( 130, 40 )
		Team:SetText( "Spectate" )
	
		local nwsImg = vgui.Create( "DImage", self.TeamSelectFrame )
		nwsImg:SetPos( 10, 30 )
		--I will use only 32x32 images
		nwsImg:SetImage( "vgui/nwsIcon" )
		nwsImg:SizeToContents( )
		nwsImg:SetSize( 32, 32 )
	
		local nwsTitle = vgui.Create( "DLabel", self.TeamSelectFrame )
		nwsTitle:SetText( "Recent News" )
		nwsTitle:SetPos( 46, 50 )
		nwsTitle:SetFont( "DefaultSmallDropShadow" )
		nwsTitle:SizeToContents( )

		local nwsHdr = vgui.Create( "DLabel", self.TeamSelectFrame )
		nwsHdr:SetText( "Recent Additions" )
		nwsHdr:SetPos( 10, 62 )
		nwsHdr:SetFont( "Trebuchet24" )
		nwsHdr:SizeToContents( )
	
		local nwsBody = vgui.Create( "DLabel", self.TeamSelectFrame )
		nwsBody:SetText( "    Some of you may have noticed the recent addition of\naccount. Please do not worry if yours is reset, the points are\n worth nothing as of right now.\n\n    If you spot any errors and would like to point them out,\n plese feel free to leave a comment at the steam group,\n http://steamcommunity.com/groups/GMDB." )
		nwsBody:SetPos( 10, 85 )
		nwsBody:SetFont( "UiBold" )
		nwsBody:SizeToContents( )
	
		--The help gui
		local helpStuff = vgui.Create( "DPropertySheet", self.TeamSelectFrame )
		helpStuff:SetPos( 10, 210 )
		helpStuff:SetSize( 490, 160 )

			local basicPanel = vgui.Create( "DPanel" )
			basicPanel:SetSize( 340, 150 )
			basicPanel.Paint = function( )
				surface.SetDrawColor( 25, 25, 25, 200 )
				surface.DrawRect( 0, 0, basicPanel:GetWide( ), basicPanel:GetTall( ) )
				surface.SetDrawColor( 255, 255, 255, 255 )
				surface.DrawOutlinedRect(0, 0, basicPanel:GetWide( ), basicPanel:GetTall( ) )
			end

				local instructions = vgui.Create( "DLabel", basicPanel )
				instructions:SetPos( 10, 10 )
				instructions:SetText( "Rules\n    This is just like playing dodgeball!\nEach team has a similar number of players. When one team runs out, the game is over.\nThe team that ran out of players lost.\n\n    When you are hit with a ball, you are out for the remainder of the round.\nIf your team wins, you get 200 points, unless you are out.\nPress F1 or F2 to bring up this menu." )
				instructions:SizeToContents( )

			local controlsPanel = vgui.Create( "DPanel" )
			controlsPanel:SetSize( 340, 150 )
			controlsPanel.Paint = function( )
				surface.SetDrawColor( 25, 25, 25, 200 )
				surface.DrawRect( 0, 0, controlsPanel:GetWide( ), controlsPanel:GetTall( ) )
				surface.SetDrawColor( 255, 255, 255, 255 )
				surface.DrawOutlinedRect(0, 0, controlsPanel:GetWide( ), controlsPanel:GetTall( ) )
			end
			
				local instructions = vgui.Create( "DLabel", controlsPanel )
				instructions:SetPos( 10, 10 )
				instructions:SetText( "Controls\n    Use the left mouse button to throw a ball. Use the right mouse button to throw the\n ball a shorter distance. To pick up a ball press E while looking at one." )
				instructions:SizeToContents( )

		helpStuff:AddSheet( "Instructions", basicPanel, "gui/silkicons/user", false, false, "Instructions" )
		helpStuff:AddSheet( "Controls", controlsPanel, "gui/silkicons/user", false, false, "Controls" )

		if ( LocalPlayer( ):IsUserGroup( "owner" ) or LocalPlayer( ):IsUserGroup( "superadmin" ) ) then
			local adminPanel = vgui.Create( "DPanel" )
			adminPanel:SetSize( 340, 150 )
			adminPanel.Paint = function( )
				surface.SetDrawColor( 25, 25, 25, 200 )
				surface.DrawRect( 0, 0, adminPanel:GetWide( ), adminPanel:GetTall( ) )
				surface.SetDrawColor( 255, 255, 255, 255 )
				surface.DrawOutlinedRect(0, 0, adminPanel:GetWide( ), adminPanel:GetTall( ) )
			end

				local ex = vgui.Create( "DButton", adminPanel )
				function ex.DoClick( ) RunConsoleCommand("db_reset_map", "3141") end
				ex:SetPos( 10, 35 )
				ex:SetSize( 130, 40 )
				ex:SetText( "Reset round." )

			helpStuff:AddSheet( "Admin", adminPanel, "gui/silkicons/user", false, false, "Administrative Panel" )
		end
end

/*---------------------------------------------------------
   Name: gamemode:HideTeam( )
   Desc: 
---------------------------------------------------------*/
function GM:HideTeam( )

	if ( IsValid( self.TeamSelectFrame ) ) then
		self.TeamSelectFrame:Remove( )
		self.TeamSelectFrame = nil
	end

end